#include "InteractiveBoard.h"


InteractiveBoard::InteractiveBoard()
{
}


InteractiveBoard::~InteractiveBoard()
{
}
void InteractiveBoard::run(){
	Board::initThreatData();
	Board board;
	int sizeBoard = 15;
	board.setSize(sizeBoard);
	vector<Vec2> vOmove;
	vector<Vec2> vXmove;
	int u, v;
	char type;
	bool findThreatSequence = false;
	vector<Vec2>sGain;
	while (true){
		cout << board << endl;
		cout << "enter o move:";
		cin >> u >> v;
		board.setValue(u, v, ENEMY_TYPE);
		vOmove.push_back(Vec2(u, v));
		cout << board << endl;
		
		if (vXmove.size() == 0){
			board.setValue(sizeBoard / 2+1, sizeBoard / 2, OUR_TYPE);
			vXmove.push_back(Vec2(sizeBoard / 2+1, sizeBoard / 2));
			
		}
		else{
			if (findThreatSequence == false){
				for each (Vec2 Xmove in vXmove)
				{
					sGain = vector<Vec2>();
			
					if (board.threatSearch(Xmove.getRow(), Xmove.getCollumn(), OUR_TYPE, sGain) == FIVE){
						board.threatSearch(Xmove.getRow(), Xmove.getCollumn(), OUR_TYPE, sGain);
						findThreatSequence = true;
						break;
					}
				}
				if (findThreatSequence == false){
					cout << "enter x move:";
					cin >> u >> v;
					board.setValue(u, v, OUR_TYPE);
					vXmove.push_back(Vec2(u, v));
				}
			}
			if (findThreatSequence == true){

				board.setValue(sGain.begin()->getRow(), sGain.begin()->getCollumn(), OUR_TYPE);
				vXmove.push_back(Vec2(sGain.begin()->getRow(), sGain.begin()->getCollumn()));
				sGain.erase(sGain.begin());
			}
		}

		
	}
	Board::clearThreatData();
}
void InteractiveBoard::manVSbot(){
	Board::initThreatData();

	Board::clearThreatData();
}